package cn.hxzy.Controller;


import cn.hxzy.common.R;
import cn.hxzy.service.TrainService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;


@RestController
@RequestMapping("/train")
public class TrainController {

    @Autowired
    private TrainService trainService;

    @GetMapping("/getTrain")
    public R getTrain(@RequestParam("startStation") String startStation,@RequestParam("endStation") String endStation){
        if (StringUtils.isEmpty(startStation)||StringUtils.isEmpty(endStation)){
            return trainService.getTrain();
        }else {
            return trainService.getTrain(startStation,endStation);
        }
    }



}

